home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1991 …esperately Seeking Seven / Desperately Seeking Seven.2mg / Dev.CD.8 / Essentials / Tools / DTS.Samples / SC11PrRecordSpy / Spy.Stds.asm < prev   
Encoding:
Assembly Source File  |  1990-07-27  |  13.4 KB  |  388 lines  |  [04] ASCII Text (0x0000)

  1. *******************************************************************************
  2. *
  3. InitTools           start
  4. *
  5. * Description:      Load and initialize the tools I need. Errors are detected
  6. *                   and FatalError is called if any occur. If there aren't any
  7. *                   errors, the list of menu templates is read and our menu-
  8. *                   bar is created.
  9. *
  10. *
  11. * Inputs:           NONE
  12. *
  13. * Outputs:          NONE
  14. *
  15. * External Refs:
  16. *                   Import FatalError
  17. *
  18. * Entry Points:     NONE
  19. *
  20. *******************************************************************************
  21.                     using Globals
  22.  
  23. ;
  24. ;   Tool Direct page offsets here
  25. ;
  26. QDDPage             equ $0000
  27. EMDPage             equ QDDPage+$0300
  28. CtlDPage            equ EMDPage+$0100
  29. MenuDPage           equ CtlDPage+$0100
  30. LEDPage             equ MenuDPage+$0100
  31. FMDPage             equ LEDPage+$0100
  32. ListDPage           equ FMDPage+$0100
  33. PMDPage             equ ListDPage+$0100
  34. ToolDPSize          equ PMDPage+$0200
  35.  
  36.                     phk                 ; Save program bank register
  37.                     plb                 ; and load it as the data bank register
  38.  
  39.                     tdc
  40.                     sta MyDP            ; Save direct register
  41.  
  42.                     _TLStartup          ; Start Tool Locator
  43.  
  44.                     pha                 ; Space for result
  45.                     _MMStartup          ; Start memory manager
  46.                     PullWord MyID       ; Save it for later use
  47.  
  48.                     _MTStartup          ; Start up Misc Tools
  49.  
  50.                     _IMStartup          ; Start integer math toolset
  51.  
  52.                     PushLong #ToolTable ; Pointer to Tool table
  53.                     _LoadTools          ; Load all RAM based tools
  54.                     bcc IT0005          ; Carry clear means no error
  55.                     brl FatalError      ; Tools can't be loaded. Fatal error!
  56.  
  57. IT0005              ANOP
  58.  
  59. ; Get memory for Tool Direct pages
  60.  
  61.                     pha                 ; Room for result
  62.                     pha
  63.                     PushLong #ToolDPSize ; Number of bytes needed
  64.                     PushWord MyID       ; ID of this application
  65.                     PushWord #attrLocked+attrFixed+attrPage+attrBank
  66.                     PushLong #0         ; Allocate them in bank 0
  67.                     _NewHandle
  68.                     bcc IT0010          ; Test carry for error
  69.                     brl FatalError      ; If no memory we got a fatal error!
  70.  
  71. IT0010              PullLong DPHandle   ; Retrieve handle to our DPage area
  72.  
  73.                     lda [DPHandle]      ; Dereference the handle to get a ptr
  74.                     sta DPPointer       ; to our direct page area and save it.
  75.  
  76.                     PushWord DPPointer  ; QuickDraw uses 3 pages of Dpage
  77.                     PushWord #ScreenMode ; Used to set all master SCB's
  78.                     PushWord #0         ; Zero means use default buf size
  79.                     PushWord MyID       ; Application ID for allocating data
  80.                     _QDStartup          ; Start QuickDraw, turn on SHR Screen
  81.                     bcc IT0015
  82.                     brl FatalError      ; If it can't be started then bomb
  83.  
  84. IT0015              _QDAuxStartUp
  85.  
  86.                     lda DPPointer       ; Create address for Event Mgr DPage by
  87.                     clc                 ; loading in the pointer to the start
  88.                     adc #EMDPage        ; of DPage and adding Evt Mgr offset.
  89.                     pha                 ; Now push it on the stack.
  90.                     PushWord #20        ; Size of event queue.
  91.                     PushWord #0         ; MouseClamp values.
  92.                     PushWord #ScreenWidth ; These will clamp mouse to screen
  93.                     PushWord #0         ; area only.
  94.                     PushWord #200
  95.                     PushWord MyID
  96.                     _EMStartup          ; Start the event manager
  97.                     bcc IT0020
  98.                     brl FatalError      ; Event manager is also a must
  99. IT0020              ANOP
  100.                     PushWord MyID
  101.                     _WindStartup
  102.                     bcc IT0025
  103.                     brl FatalError
  104. IT0025              ANOP
  105.                     PushWord MyID
  106.                     lda DPPointer
  107.                     clc
  108.                     adc #CtlDPage
  109.                     pha
  110.                     _CtlStartup
  111.                     bcc IT0030
  112.                     brl FatalError
  113. IT0030              ANOP
  114.  
  115.                     PushWord MyID
  116.                     lda DPPointer
  117.                     clc
  118.                     adc #MenuDPage
  119.                     pha
  120.                     _MenuStartUp
  121.                     bcc IT0035
  122.                     brl FatalError
  123. IT0035              ANOP
  124.  
  125.                     PushWord MyID
  126.                     lda DPPointer
  127.                     clc
  128.                     adc #LEDPage
  129.                     pha
  130.                     _LEStartUp
  131.                     bcc IT0040
  132.                     brl FatalError
  133. IT0040              ANOP
  134.  
  135.                     PushWord MyID
  136.                     _DialogStartup
  137.                     bcc IT0045
  138.                     brl FatalError
  139. IT0045              ANOP
  140.  
  141.                     _ScrapStartup       ; No errors possible for this call
  142.  
  143.                     _DeskStartup        ; No error possible for this call
  144.  
  145. ; insert application specific tools here
  146.  
  147.                     PushWord MyID
  148.                     lda DPPointer
  149.                     clc
  150.                     adc #FMDPage
  151.                     pha
  152.                     _FMStartUp
  153.                     bcc IT0050
  154.                     brl FatalError
  155. IT0050              ANOP
  156.  
  157.                     _ListStartup
  158.  
  159.                     PushWord MyID
  160.                     lda DPPointer
  161.                     clc
  162.                     adc #PMDPage
  163.                     pha
  164.                     _PMStartUp
  165.                     bcc IT0055
  166.                     brl FatalError
  167. IT0055              ANOP
  168.  
  169.                     PushLong #0
  170.                     _RefreshDeskTop
  171.  
  172. ;
  173. ; Create the menus I need
  174. ;
  175.  
  176.                     ldx #MenuPtrLen-4   ; Get a pointer to the last menu        
  177. loop                phx                 ; Save menu table index on the stack
  178.                     pha                 ; Push on space for the menu handle
  179.                     pha                 ;   returned by NewMenu
  180.                     lda MenuPtr+2,x     ; Push on the pointer to the template
  181.                     pha                 ;   to be used by NewMenu when
  182.                     lda MenuPtr,x       ;   creating the menu
  183.                     pha
  184.                     _NewMenu            ; Create a new menu
  185.                     PushWord #0         ; Tell InsertMenu where to put it
  186.                     _InsertMenu         ; Insert it.
  187.                     plx                 ; Get our index back off the stack
  188.                     dex                 ; Point to the next template pointer
  189.                     dex
  190.                     dex
  191.                     dex
  192.                     bpl loop            ; Go back up if not done yet.
  193.  
  194.                     PushWord #1         ; Add NDA's
  195.                     _FixAppleMenu
  196.  
  197.                     PushWord #0         ; Now call CalcMenuSize for all menus
  198.                     _FixMenuBar
  199.                     PullWord MenuHeight
  200.  
  201.                     _DrawMenuBar        ; Finally, draw it.
  202.  
  203.                     RTS
  204.  
  205. ToolTable           dc i2'10'           ; Data Block for LoadTools call
  206.                     dc i2'14,$0100'     ; Window Manager
  207.                     dc i2'15,$0100'     ; Menu Manager
  208.                     dc i2'16,$0100'     ; Control Manager
  209.                     dc i2'18,$0100'     ; QD Aux
  210.                     dc i2'19,$0100'     ; Print Manager
  211.                     dc i2'20,$0100'     ; LineEdit tool set
  212.                     dc i2'21,$0100'     ; Dialog Manager
  213.                     dc i2'22,$0100'     ; Scrap manager
  214.                     dc i2'27,$0100'     ; Font Manager
  215.                     dc i2'28,$0100'     ; List Manager
  216.  
  217.                     end
  218.  
  219.                     EJECT
  220. *******************************************************************************
  221. *
  222. FatalError          start
  223. *
  224. * Description:      Routine that is called whenever a tool sends back an error
  225. *                   that can not be recovered from. This routine prints the
  226. *                   error on the screen, waits for a keypress then quits back
  227. *                   to whoever started this application up!
  228. *
  229. *
  230. * Inputs:           A = Error number
  231. *
  232. * Outputs:          NONE (program exits)
  233. *
  234. * External Refs:
  235. *                   Import CloseTools
  236. *
  237. * Entry Points:     NONE
  238. *
  239. *******************************************************************************
  240.                     using Globals
  241.  
  242.                     pha                 ; Push the error code
  243.                     PushLong #ErrNumStr ; Address of storage area
  244.                     PushWord #4         ; Length of string
  245.                     _Int2Hex
  246.  
  247.                     _GrafOff            ; If QD Started, shut off graphics
  248.  
  249.                     PushLong #ErrStr    ; Write error message to the screen
  250.                     _WriteCString
  251.  
  252.                     pha                 ; Space for result
  253.                     PushWord #0         ; No echo
  254.                     _ReadChar           ; Wait for a key to be pressed
  255.                     pla                 ; Discard the key
  256.  
  257.                     jsr CloseTools      ; Shut down all the tools in case
  258. ;                                         any got started up
  259.  
  260.                     _Quit QuitParms     ; Quit back to where we came from.
  261.  
  262.                     brk $FF             ; If the quit fails then just break
  263.                     
  264. ErrStr              dc c'A fatal error has occured $'
  265. ErrNumStr           dc c'xxxx   press any key to exit',i1'0'
  266.  
  267.                     end
  268.  
  269.                     EJECT
  270. *******************************************************************************
  271. *
  272. CloseTools          start
  273. *
  274. * Description:      Shut down the tools I started.
  275. *
  276. *
  277. * Inputs:           NONE
  278. *
  279. * Outputs:          NONE
  280. *
  281. * External Refs:    NONE
  282. *
  283. * Entry Points:     NONE
  284. *
  285. *******************************************************************************
  286.                     using Globals
  287.  
  288.                     _PMShutDown
  289.                     _ListShutDown
  290.                     _FMShutDown
  291.                     _DeskShutDown
  292.                     _ScrapShutDown
  293.                     _DialogShutDown
  294.                     _LEShutDown
  295.                     _MenuShutDown
  296.                     _CtlShutDown
  297.                     _WindShutDown
  298.  
  299.                     _EMShutDown
  300.                     _QDAuxShutdown
  301.                     _QDShutDown
  302.                     _MTShutDown
  303.  
  304.                     PushLong DPHandle   ; Dispose of all that DP memory
  305.                     _DisposeHandle
  306.  
  307.                     PushWord MyID
  308.                     _MMShutDown
  309.                     _TLShutDown
  310.  
  311.                     rts
  312.                     end
  313.  
  314.                     EJECT
  315. *******************************************************************************
  316. *
  317. doAbout             start
  318. *
  319. * Description:      Bring up an Alert Dialog box with my name in it.
  320. *
  321. * Inputs:           NONE
  322. *
  323. * Outputs:          NONE
  324. *
  325. * External Refs:    NONE
  326. *
  327. * Entry Points:     NONE
  328. *
  329. *******************************************************************************
  330.                     using Globals
  331.  
  332.                     pha                 ; space for result
  333.                     PushLong #AboutBox  ; pointer to dialog template
  334.                     PushLong #0         ; pointer to a filter proc
  335.                     _NoteAlert
  336.                     pla                 ; get the item hit and dispose
  337.  
  338.                     rts
  339.  
  340. ; About Box alert template
  341.  
  342. AboutBox            dc i2'30,30,100,590'                    ; for 320 use 30,30,100,290
  343.                     dc i2'1'            ; this is alert # 1
  344.                     dc i1'$80'          ; draw for this stage
  345.                     dc i1'$81'          ; draw for this stage
  346.                     dc i1'$82'          ; draw for this stage
  347.                     dc i1'$83'          ; draw for this stage
  348.                     dc i4'OKButton'     ; ok button for the alert
  349.                     dc i4'AboutTitle'   ; title of the program
  350.                     dc i4'AboutAut'     ; author
  351.                     dc i4'AboutVers'    ; version number string
  352.                     dc i4'0'            ; nil to end the list
  353.  
  354. OKBTitle            dc i1'2',c'OK'
  355. OKButton            dc i2'1'
  356.                     dc i2'50,500,65,550'
  357.                     dc i2'buttonItem'
  358.                     dc i4'OKBTitle'
  359.                     dc i2'0'
  360.                     dc i2'0'            ; item flag
  361.                     dc i4'0'            ; no color table
  362.  
  363. AboutTitle          dc i2'2'
  364.                     dc i2'10,100,20,550'
  365.                     dc i2'statText+itemDisable'
  366.                     dc i4'TitleString'
  367.                     dc i2'0'
  368.                     dc i2'0'            ; item flag
  369.                     dc i4'0'            ; no color table
  370.  
  371. AboutAut            dc i2'3'
  372.                     dc i2'25,100,35,550'
  373.                     dc i2'statText+itemDisable'
  374.                     dc i4'AutString'
  375.                     dc i2'0'
  376.                     dc i2'0'            ; item flag
  377.                     dc i4'0'            ; no color table
  378.  
  379. AboutVers           dc i2'4'
  380.                     dc i2'40,100,50,550'
  381.                     dc i2'statText+itemDisable'
  382.                     dc i4'VersString'
  383.                     dc i2'0'
  384.                     dc i2'0'            ; item flag
  385.                     dc i4'0'            ; no color table
  386.  
  387.                     end
  388.